-
Notifications
You must be signed in to change notification settings - Fork 8.1k
lib: Introduce a way to set minimum file descriptors count #97715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib: Introduce a way to set minimum file descriptors count #97715
Conversation
233980b
to
9d95c61
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, just some nits
lib/os/Kconfig
Outdated
specify ZVFS_OPEN_ADD_SIZE_* options, these will be added together | ||
and the sum will be compared to the ZVFS_OPEN_MAX value. | ||
If the sum is greater than the ZVFS_OPEN_MAX option (even if this | ||
has the default 0 value), then the actual heap size will be rounded up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has the default 0 value), then the actual heap size will be rounded up | |
has the default 0 value), then the actual file descriptor count will be rounded up |
lib/os/Kconfig
Outdated
This option can be set to force setting a smaller file descriptor | ||
size than what's specified by enabled subsystems. This can be useful |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file descriptor size
sounds a bit odd, I think it should either be file descriptor table size
or simply file descriptor count
is used when listening or sending network traffic. This is very | ||
similar as one could call a network socket in some other systems. | ||
|
||
config ZVFS_OPEN_ADD_SIZE_NET |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wonder if we should do the same for the TLS sockets (for config NET_SOCKETS_TLS_MAX_CONTEXTS
, if enabled). I think those TLS contexts should add up to the regular net contexts to represent the acutal limit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can add sub-option for TLS contexts.
9d95c61
to
18d1667
Compare
|
Instead of user trying to figure out what is the amount of file / socket descriptors in the system, let the various subsystems etc. specify their need using a Kconfig option. The build system will then add these smaller values together and set a suitable file descriptor count in the system. This works the same way as the heap size calculation introduced in commit 3fbf124 Signed-off-by: Jukka Rissanen <[email protected]>
The file descriptor table size is now controlled by adding together the values of CONFIG_ZVFS_OPEN_ADD_SIZE_* options. Signed-off-by: Jukka Rissanen <[email protected]>
Make sure we always allocate space for stdin, stdout and stderr file descriptors if Posix device io option is enabled. Signed-off-by: Jukka Rissanen <[email protected]>
Create a Kconfig entry that allows the application to control how many sockets it needs. Signed-off-by: Jukka Rissanen <[email protected]>
The ZVFS_OPEN_ADD_SIZE_ is used as a prefix for matching specific Kconfig option names, i.e. it's not a real option in itself. Signed-off-by: Jukka Rissanen <[email protected]>
The number of net_context now determines the minimum amount of network sockets that are to be allocated. Signed-off-by: Jukka Rissanen <[email protected]>
Make sure that the CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS will reflect the number of required file descriptors in the system. Signed-off-by: Jukka Rissanen <[email protected]>
Set the minimum number of sockets that are used by the wifi snippets. Signed-off-by: Jukka Rissanen <[email protected]>
Remove unneeded CONFIG_ZVFS_OPEN_MAX config option as it is now controlled by number of net_context i.e., CONFIG_NET_MAX_CONTEXTS Some of the samples now use CONFIG_ZVFS_OPEN_ADD_SIZE_NET_SAMPLE to specify the sample socket needs. Signed-off-by: Jukka Rissanen <[email protected]>
The number of file/socket descriptors is now determined by CONFIG_ZVFS_OPEN_ADD_SIZE_* options and the networking side already sets the minimum values so the CONFIG_ZVFS_OPEN_MAX option is not needed. Signed-off-by: Jukka Rissanen <[email protected]>
Add CONFIG_ZVFS_OPEN_IGNORE_MIN=y so that we can set the CONFIG_ZVFS_OPEN_MAX without specifying individual sub values. This is just specific to this test and not something that needs to be done in other tests. Signed-off-by: Jukka Rissanen <[email protected]>
Either remove the option from conf file or adjust its value by using CONFIG_ZVFS_OPEN_ADD_SIZE_NET option because the max number of socket descriptors is now calculated dynamically at built time. Signed-off-by: Jukka Rissanen <[email protected]>
As the CONFIG_ZVFS_OPEN_MAX is set to 0 by default, we must use ZVFS_OPEN_SIZE in the tests. Signed-off-by: Jukka Rissanen <[email protected]>
18d1667
to
e357f43
Compare
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look OK.
But I don't see descriptors added when you enable DNS resolver. That is typically the case why I have been required the change the number of descriptors.
I will investigate that, did not spot anything obviously wrong in the configurations while I was going through the samples/tests. It is possible that we get enough sockets already with the current config options in this PR so no special treatment for DNS is needed. |
Instead of user trying to figure out what is the amount of file / socket descriptors in the system, let the various subsystems etc. specify their need using a Kconfig option. The build system will then add these smaller values together and set a suitable file descriptor count in the system.
This works the same way as the heap size calculation introduced in commit 3fbf124